<?php

namespace App\Models;

use App\Models\User\WxUser;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class WxAuthentication extends Model
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'wx_authentication';

    protected static function boot()
    {
        parent::boot();
        static::deleted(function ($model) {
            WxChat::where('expand_type', 109)->where('expand_id', $model->id)->forceDelete();
        });
    }

    public function user()
    {
        return $this->hasOne(WxUser::class, "id", "user_id");
    }

}
